package com.gavin.demo4fresco.module.navigation;

import android.net.Uri;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;

import com.facebook.drawee.backends.pipeline.Fresco;
import com.facebook.drawee.interfaces.DraweeController;
import com.facebook.drawee.view.SimpleDraweeView;
import com.gavin.demo4fresco.R;
import com.gavin.demo4fresco.config.GlobalVars;

public class DynamicDemoActivity extends AppCompatActivity {
    /**
     * Gif 动态图
     */
    private SimpleDraweeView mAnimatedGifView;
    /**
     * Webp 动态图
     */
    private SimpleDraweeView mAnimatedWebpView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_dynamic_demo);

        mAnimatedGifView = (SimpleDraweeView) findViewById(R.id.animated_gif)
        ;
        DraweeController animatedGifController = Fresco.newDraweeControllerBuilder()
                .setUri(Uri.parse(GlobalVars.URLS[GlobalVars.URLS.length - 2]))
                .setOldController(mAnimatedGifView.getController())
                .setAutoPlayAnimations(true)
                .build();
        mAnimatedGifView.setController(animatedGifController);

        mAnimatedWebpView = (SimpleDraweeView) findViewById(R.id.animated_webp);
        DraweeController animatedWebpController = Fresco.newDraweeControllerBuilder()
                .setAutoPlayAnimations(true)
                .setOldController(mAnimatedWebpView.getController())
                .setUri(Uri.parse(GlobalVars.URLS[GlobalVars.URLS.length - 3]))
                .build();
        mAnimatedWebpView.setController(animatedWebpController);
    }
}
